package com.zy.yun.controller.common;

import com.zy.yun.plugins.ueditor.ActionEnter;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * Created by ldb on 2017/4/9.
 */
//@Api(description = "ueditor富文本编辑器",tags = "富文本管理")
@Controller
@RequestMapping("ueditor")
public class UEditorController {

    /**
     * 功能描述:config.json配置
     * @param:
     * @return:
     * @auther: wangyanwei
     * @date: 2019/4/21 22:14
     */
//    @ApiOperation("config.json配置")
    @RequestMapping(value="/config",method = {RequestMethod.POST, RequestMethod.GET})
    public void config(HttpServletRequest request, HttpServletResponse response) {
        response.setContentType("application/json");
        String rootPath = request.getSession().getServletContext().getRealPath("/");
        try {
            String exec = new ActionEnter(request, rootPath).exec();
            PrintWriter writer = response.getWriter();
            writer.write(exec);
            writer.flush();
            writer.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
